package com.mofe.zxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mofe.zxy.domain.Admin;
import com.mofe.zxy.domain.AdminUserDetail;
import com.mofe.zxy.service.AdminService;
import com.mofe.zxy.mapper.AdminMapper;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
* @author imzxy
* @description 针对表【t_admin】的数据库操作Service实现
* @createDate 2022-04-12 21:56:21
*/
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin>
    implements AdminService  {

    @Override
    public AdminUserDetail loadUserByUsername(String s) throws UsernameNotFoundException {

        Admin one = this.getOne(new LambdaQueryWrapper<Admin>().eq(Admin::getAdminName, s).last("limit 1"));
        AdminUserDetail adminUserDetail = new AdminUserDetail(one.getAdminId(),one.getAdminName(), one.getPassword(), new ArrayList<>());

        return adminUserDetail;
    }
}




